package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhServiceOrderPartsLog;
import com.ruoyi.zsyh.service.IZsyhServiceOrderPartsLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配件单操作记录Controller
 * 
 * @author yuexl
 * @date 2022-09-06
 */
@Controller
@RequestMapping("/zsyh/serviceOrderPartsLog")
public class ZsyhServiceOrderPartsLogController extends BaseController
{
    private String prefix = "zsyh/serviceOrderPartsLog";

    @Autowired
    private IZsyhServiceOrderPartsLogService zsyhServiceOrderPartsLogService;

    @RequiresPermissions("zsyh:serviceOrderPartsLog:view")
    @GetMapping()
    public String serviceOrderPartsLog()
    {
        return prefix + "/serviceOrderPartsLog";
    }

    /**
     * 查询配件单操作记录列表
     */
    @RequiresPermissions("zsyh:serviceOrderPartsLog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhServiceOrderPartsLog zsyhServiceOrderPartsLog)
    {
        startPage();
        List<ZsyhServiceOrderPartsLog> list = zsyhServiceOrderPartsLogService.selectZsyhServiceOrderPartsLogList(zsyhServiceOrderPartsLog);
        return getDataTable(list);
    }

    /**
     * 导出配件单操作记录列表
     */
    @RequiresPermissions("zsyh:serviceOrderPartsLog:export")
    @Log(title = "配件单操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhServiceOrderPartsLog zsyhServiceOrderPartsLog)
    {
        List<ZsyhServiceOrderPartsLog> list = zsyhServiceOrderPartsLogService.selectZsyhServiceOrderPartsLogList(zsyhServiceOrderPartsLog);
        ExcelUtil<ZsyhServiceOrderPartsLog> util = new ExcelUtil<ZsyhServiceOrderPartsLog>(ZsyhServiceOrderPartsLog.class);
        return util.exportExcel(list, "配件单操作记录数据");
    }

    /**
     * 新增配件单操作记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存配件单操作记录
     */
    @RequiresPermissions("zsyh:serviceOrderPartsLog:add")
    @Log(title = "配件单操作记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhServiceOrderPartsLog zsyhServiceOrderPartsLog)
    {
        return toAjax(zsyhServiceOrderPartsLogService.insertZsyhServiceOrderPartsLog(zsyhServiceOrderPartsLog));
    }

    /**
     * 修改配件单操作记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhServiceOrderPartsLog zsyhServiceOrderPartsLog = zsyhServiceOrderPartsLogService.selectZsyhServiceOrderPartsLogById(id);
        mmap.put("zsyhServiceOrderPartsLog", zsyhServiceOrderPartsLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存配件单操作记录
     */
    @RequiresPermissions("zsyh:serviceOrderPartsLog:edit")
    @Log(title = "配件单操作记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhServiceOrderPartsLog zsyhServiceOrderPartsLog)
    {
        return toAjax(zsyhServiceOrderPartsLogService.updateZsyhServiceOrderPartsLog(zsyhServiceOrderPartsLog));
    }

    /**
     * 删除配件单操作记录
     */
    @RequiresPermissions("zsyh:serviceOrderPartsLog:remove")
    @Log(title = "配件单操作记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhServiceOrderPartsLogService.deleteZsyhServiceOrderPartsLogByIds(ids));
    }
}
